fix: resolve failing tests and type errors across api and shared packages#45
Open
stooit wants to merge 1 commit into
Open
fix: resolve failing tests and type errors across api and shared packages#45stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
…ages - Implement paginate() utility in shared package (page slicing, total, totalPages) - Fix auth middleware so public-route method check handles HTTP method casing - Align User type and users route on consistent field name - Add missing badRequest import in users route - Include bun-types in tsconfig so bun:test and process resolve (no new deps) All 22 tests pass; tsc --noEmit is clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes all 9 failing tests and all type errors in the TypeScript Hono API repo. After this change
bun testreports 22 pass / 0 fail andbunx tsc --noEmitexits clean (0 errors).Changes
shared/src/utils/pagination.ts— Implemented the previously-stubbedpaginate()utility: 1-indexed page slicing (start = (page-1)*size),total,totalPagesviaMath.ceilwith asize > 0guard, and correct empty-array / partial-last-page handling.api/src/middleware/auth.ts— Fixed the public-route check so it correctly matches HTTP method casing (Hono provides uppercase methods), soPOST /usersis correctly treated as public. Also made theprocess.envtoken lookup safe whereprocessmay not be in scope.shared/src/types.ts+api/src/routes/users.ts— Aligned theUsertype and the users route on a single consistent field name (removed the cross-package mismatch).api/src/routes/users.ts— Added the missingbadRequestimport, soPOST /usersreturns 400 for missing fields.tsconfig.json— Addedbun-types(already installed; no new dependency) tocompilerOptions.typessobun:testand theprocessglobal resolve undertsc.Verification
bun test→ 22 pass, 0 failbunx tsc --noEmit→ exit 0, cleanNotes / assumptions
?? "test-token"fallback in the auth middleware that silently accepts a hardcoded token when the env token is unset. This predates this work and is out of scope, flagged for awareness.types.tsdescribing the original bug was left in place (cosmetic only).